#include <bits/stdc++.h>
using namespace std;
int read()
{
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}
	return x*f;
}
void write(int x)
{
	if(x<0)
	{
		putchar('-');
		write(-x);
		return;
	}
	if(x<10)
	{
		putchar(x+'0');
		return;
	}
	write(x/10);
	putchar(x%10+'0');
	return;
}
struct node
{
	double x,y;
};
int T;
int n,m,L,V;
int d[100005];
int v[100005];
int a[100005];
int p[100005];
double id;
vector<node> s;
bool find1(double lef,double rig)
{
	int le=1,ri=m;
	while(le<=ri)
	{
		int mid=(le+ri)>>1;
		if(lef<=p[mid]&&p[mid]<=rig)
		{
			return 1;
		}
		if(p[mid]<lef)
		{
			le=mid+1;
		}
		else
		{
			ri=mid-1;
		}
	}
	return 0;
}
int find2(double rig)
{
	int le=1,ri=m,ans;
	while(le<=ri)
	{
		int mid=(le+ri)>>1;
		if(p[mid]<=rig)
		{
			ans=mid;
			le=mid+1;
		}
		else
		{
			ri=mid-1;
		}
	}
	return ans;
}
bool cmp(node a1,node a2)
{
	return a1.y<a2.y;
}
int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	T=read();
	while(T--)
	{
		n=read();
		m=read();
		L=read();
		V=read();
		for(int i = 1;i <= n;i++)
		{
			d[i]=read();
			v[i]=read();
			a[i]=read();
		}
		for(int i = 1;i <= m;i++)
		{
			p[i]=read();
		}
		sort(p+1,p+m+1);
		// for(int i = 1;i <= n;i++)
		// {
		// 	if(a[i]==0)
		// 	{
		// 		continue;
		// 	}
			
		// }
		// for(int i = 1;i <= n;i++)
		// {
		// 	cout<<id[i]<<endl;
		// }
		s.clear();
		for(int i = 1;i <= n;i++)
		{
			if(a[i]==0)
			{
				if(v[i]>V)
				{
					// cout<<i<<endl;
					double lef=d[i];
					double rig=L;
					if(find1(lef,rig))
					{
						s.push_back({lef,rig});
					}
				}
				continue;
			}
			id=(double)((double)V*V-v[i]*v[i])/(2.0*a[i])+d[i];
			if(a[i]>0)
			{
				if(id<=L)
				{
					// cout<<i<<endl;
					double lef=id+0.0001;
					double rig=L;
					if(find1(lef,rig))
					{
						s.push_back({lef,rig});
					}
				}
			}
			else
			{
				if(v[i]>V&&id>=0)
				{
					// cout<<i<<endl;
					double lef=d[i];
					double rig=id-0.0001;
					if(find1(lef,rig))
					{
						s.push_back({lef,rig});
					}
				}
			}
		}
		// for(auto&&i:s)
		// {
		// 	cout<<i.x<<' '<<i.y<<endl;
		// }
		write((int)(s.size()));
		// cout<<s.size();
		putchar(' ');
		sort(s.begin(),s.end(),cmp);
		int now=-1;
		int cnt=0;
		for(auto&&i:s)
		{
			if(i.x<=now&&now<=i.y)continue;
			int k=find2(i.y);
			now=p[k];
			cnt++;
		}
		write(m-cnt);
		putchar('\n');
	}
	return 0;
}